package com.exp.bookhouse.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2     //开启Swagger2
public class SwaggerConfig {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //配置扫描接口的方式，如按包扫描
                //basePackage: 扫描指定的包
                //any:扫描全部
                //none: 不扫描
                //withMethodAnnotation: 扫描方法上指定的注解
                //withClassAnnotation: 扫描类上指定的注解
                .apis(RequestHandlerSelectors.basePackage("com.exp.bookhouse.controller"))
                //过滤什么路径，或只扫描指定路径下的接口,不存在则显示No operations defined in spec!
                //.paths(PathSelectors.ant("/linging/*"))
                .build();
    }


    public ApiInfo apiInfo(){
        //作者信息
        Contact author = new Contact("bbfeng", "https://gitee.com/bbfeng/spring-boot-final-exp/tree/master/src/main/java/com/exp/bookhouse", "1731896471@qq.com");

        return new ApiInfo(
                "bookstore的Swagger日志",
                "",
                "1.0",
                "",
                author,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList()
        );
    }

}